package com.ehotting.edsta.diagnosisPredict.controller;

import com.ehotting.eaf.core.domain.R;
import com.ehotting.eaf.core.web.controller.BaseController;
import com.ehotting.eaf.core.web.domain.diagnosisPredict.PageDto;
import com.ehotting.eaf.core.web.domain.diagnosisPredict.Response;
import com.ehotting.edsta.diagnosisPredict.domain.dto.ProjectDto;
import com.ehotting.edsta.diagnosisPredict.domain.dto.ProjectSearchDto;
import com.ehotting.edsta.diagnosisPredict.feign.ModelManagerFeignService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "ModelManagerController",description = "模型管理接口")
@RestController
@RequestMapping("/modelManager")
public class ModelManagerController extends BaseController {

    @Autowired
    private ModelManagerFeignService modelManagerFeignService;

    /**
     * 模型查询列表
     * @param projectSearchDto
     * @return
     */
    @ApiOperation(value = "模型查询列表",notes = "返回的数据类型：PageDto\\<ProjectDto\\>")
    @PostMapping("/searchPage")
    public R<PageDto<ProjectDto>> searchPage(@RequestBody ProjectSearchDto projectSearchDto){
        Response<PageDto<ProjectDto>> data = modelManagerFeignService.searchPage(projectSearchDto);
        return R.convert(data);
    }

    /**
     * 模型删除
     * @param idList
     * @return
     */
    @ApiOperation(value = "模型删除",notes = "")
    @PostMapping("/batch")
    public R<Boolean> batch(long[] idList){
        Response<Boolean> data = modelManagerFeignService.batch(idList);
        return R.convert(data);
    }


    /**
     * 获取模型详情
     * @param id
     * @return
     */
    @ApiOperation(value = "获取模型详情",notes = "返回的数据类型：ProjectDto")
    @GetMapping(value = "/{id}")
    public R<ProjectDto> get(@PathVariable("id") Long id) {
        return R.convert(modelManagerFeignService.get(id));
    }

    /**
     * 项目信息保存
     * @return
     */
    @ApiOperation(value = "项目信息保存",notes = "返回的数据类型：ProjectDto")
    @PostMapping(value = "/save")
    public R<ProjectDto> projectSave(@RequestBody ProjectDto dto) {
        return R.convert(modelManagerFeignService.projectSave(dto));
    }

}
